#pragma once
#include<Windows.h>
#include<string.h>
#include "defination.h"
#include "resource.h"
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL InitClass(LPCTSTR lpszClassName, LPCTSTR lpszMenuName, HINSTANCE hInstance)
{
	WNDCLASS a;
	a.style = CS_HREDRAW | CS_VREDRAW;
	a.hInstance = hInstance;
	a.lpfnWndProc = MainWndProc;
	a.lpszClassName = lpszClassName;
	a.lpszMenuName = lpszMenuName;
	a.cbClsExtra = 0;
	a.cbWndExtra = 0;
	a.hIcon = LoadIcon(0, IDI_APPLICATION);
	a.hCursor = LoadCursor(0, IDC_ARROW);
	a.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	if (!RegisterClass(&a))
	{
		return 0;
	}
	else
	{
		return 1;
	}
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}
	return DefWindowProc(hWnd, uMsg, lParam, wParam);
}
int GetLong(int a)
{
	int num = 0;
	for (; a > 1;)
	{
		num++;
		a /= 10;
	}
	return num;
}